package com.linkey.demo.services.test.service.impl;


import com.linkey.demo.services.test.entity.DataOriginal;
import com.linkey.demo.services.test.tsMapper.DataOriginalMapper;
import com.linkey.demo.services.test.service.DataOriginalService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
import com.linkey.demo.services.test.dto.DataOriginalInsertDTO;
import com.linkey.demo.services.test.vo.DataOriginalVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.linkey.demo.services.test.dto.DataOriginalPageDTO;
import com.linkey.demo.services.test.vo.DataOriginalPageVO;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhujh
 * @since 2021-03-29
 */
@Service
@Slf4j
public class DataOriginalServiceImpl extends ServiceImpl<DataOriginalMapper, DataOriginal> implements DataOriginalService {

            @Transactional(rollbackFor = Exception.class, transactionManager = "timeScaleTransactionManager")
        @Override
    public void add(DataOriginalInsertDTO dataOriginalInsertDTO) {
        DataOriginal dataOriginal = new DataOriginal();
        BeanUtils.copyProperties(dataOriginalInsertDTO, dataOriginal);
        save(dataOriginal);
    }
    
            @Transactional(rollbackFor = Exception.class, transactionManager = "timeScaleTransactionManager")
        @Override
    public void update(DataOriginalInsertDTO dataOriginalInsertDTO) {
        DataOriginal dataOriginal = new DataOriginal();
        BeanUtils.copyProperties(dataOriginalInsertDTO, dataOriginal);
        updateById(dataOriginal);
    }
    
    @Override
    public DataOriginalVO get(Long id) {
        DataOriginal dataOriginal = getById(id);
        DataOriginalVO dataOriginalVO = new DataOriginalVO();
        BeanUtils.copyProperties(dataOriginal, dataOriginalVO);
        return dataOriginalVO;
    }
    
    @Override
    public IPage<DataOriginalPageVO> pageList(DataOriginalPageDTO dataOriginalPageDTO) {
        IPage<DataOriginalPageVO> pages = baseMapper.pageList(dataOriginalPageDTO);
        return pages;
    }
    
            @Transactional(rollbackFor = Exception.class, transactionManager = "timeScaleTransactionManager")
        @Override
    public void delete(Long id) {
        removeById(id);
    }
    
            @Transactional(rollbackFor = Exception.class, transactionManager = "timeScaleTransactionManager")
        @Override
    public void batchDelete(List<Long> ids) {
        removeByIds(ids);
    }
    }
